package controllers

/**
  * Created by yz on 2017/5/31.
  */

import java.sql.Date
import javax.inject.Inject

import play.api.mvc._
import dao._
import models.Tables._
import scala.concurrent.ExecutionContext.Implicits.global

class IndexController @Inject()(visitorDao: VisitorDao,cc: ControllerComponents) extends AbstractController(cc) {

  def toIndex = Action.async { implicit request =>
    val ip = request.remoteAddress
    val time = new Date(new java.util.Date().getTime)
    val visitor = VisitorRow(ip, time)
    visitorDao.insertOrUpdate(visitor).map { x =>
      Ok(views.html.index())
    }
  }

  def developing = Action {

    Ok(views.html.developing())
  }

}
